<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <meta content="telephone=no,email=no" name="format-detection"/>
    <meta name="apple-mobile-web-app-capable" content="yes"/>
    <meta content="yes" name="apple-touch-fullscreen">
    <link rel="stylesheet" href="css/amazeui.min.css">
    <link rel="stylesheet" href="css/swiper-3.4.2.min.css">
    <link rel="stylesheet" href="css/common.css">
    <link rel="stylesheet" href="css/index.css">
    <link rel="stylesheet" href="js/common.css">

    <script src="js/html5shiv.min.js"></script>
    <script src="js/respond.min.js"></script>

    <!-------------zhanglonghai start------------------------>
    <script type="text/javascript" src="js/http.js"></script>
    <script type="text/javascript" src="js/jquery-3.1.1.min.js"></script>
    <script type="text/javascript" src="js/alertPopShow.js"></script>
    <script type="text/javascript" src="js/index.js"></script>

    <script>
        $(function(){
            //城市下拉
            var arr = (decodeURI(location.hash) || "").replace(/^\#/,'').split("&");
            $(".cityname").html(arr[0]||"北京");
            checklogin();
            function checklogin(){
                $.ajax({
                    url:url+'checkloginis',
                    dataType:'json',
                    type:'post',
                    async:true,
                    data:{

                    },
                    success:function(result){
                        // console.log(result);
                        var status = result.status;
                        var code = result.code;
                        var data = result.data;
                        var html='';
                        if(code=='1007') {
                            html='<a class="right_teacher login-btn" href="#">'+data['xingming']+'</a><a class="right_teacher logout"  href="javascript:logout();">退出</a> <a class="right_teacher " href="approve.html">认证信息</a>';

                            $('#info').html(html);
                            $('.logout').click(function(){
                                logout();
                            });
                        }else{

                        }
                    },
                    error:function(){
                        console.log();
                    }
                })
            }
            function logout(){
                $.ajax({
                    url:url+'logout',
                    dataType:'json',
                    type:'post',
                    async:true,
                    data:{

                    },
                    success:function(result){
                        // console.log(result);
                        var status = result.status;
                        var code = result.code;
                        var data = result.data;
                        var html='';
                        if(status==1&code=='1000') {
                            alert(data);
                            window.location.reload();
                        }else{

                        }
                    },
                    error:function(){
                        console.log();
                    }
                })
            }
            $('.login-btn').on('click', function(){
                var html = "<label>用户名：<input class='confirm_input' placeholder='请输入用户名或手机号' type='text'></label></br><label>密码：<input type='password' class='confirm_input confirm_input2' placeholder='请输入密码'></label>" +
                        "</br><label><select class='type'><option value='teacher'>我是老师</option><option value='student'>我是学生</option></select></label>";
                popTipShow.confirm('登录',html,['确 定','取 消'],
                        function(e){
                            //callback 处理按钮事件
                            var button = $(e.target).attr('class');
                            if(button == 'ok'){
                                if(null==$(".confirm_input").val() || ""==$(".confirm_input").val()){
                                    webToast("用户名不能为空！","bottom", 3000);
                                    return;
                                }
                                if(null==$(".confirm_input2").val() || ""==$(".confirm_input").val()){
                                    webToast("密码不能为空！","bottom", 3000);
                                    return;
                                }
                                var username =$(".confirm_input").val();
                                var password = $(".confirm_input2").val();
                                var type = $(".type").val();
                                $.ajax({
                                    url:url+'login',
                                    dataType:'json',
                                    type:'post',
                                    async:true,
                                    data:{
                                        'username':username,
                                        'password':password,
                                        'flag':type
                                    },
                                    success:function(result){
                                        // console.log(result);
                                        var status = result.status;
                                        var code = result.code;
                                        var data = result.data;
                                        var html='';
                                        if(status==1&&code=='1000') {
                                            html='<a class="right_teacher login-btn" href="#">'+data['xingming']+'</a><a class="right_teacher logout"  href="javascript:logout();">退出</a> <a class="right_teacher " href="approve.html">认证信息</a>';
                                            $('#info').html(html);
                                            $('.logout').click(function(){
                                                logout();
                                            });
                                        }else{
                                            alert('登录失败');
                                        }
                                    },
                                    error:function(){

                                    }
                                })
                                this.hide();
                                //按下确定按钮执行的操作
                                //todo ....
                            }

                            if(button == 'cancel') {
                                //按下取消按钮执行的操作
                                //todo ....
                                this.hide();
                                /* setTimeout(function() {
                                 webToast("您选择“取消”了","top", 2000);
                                 }, 300);*/
                            }
                        }
                );
            });
        })

    </script>
    <title>学戏</title>
</head>
<body>

<header>
    <div class="header_log">
        <a href="city.html">
            <div id="cityname">
                <span class="cityname">扬州</span>
                <div class="icon-drop">
                    <em></em>
                </div>
            </div>
        </a>
        <!----------------zhanglonghai start--------------------------------->
        <div id="info">
            <a class="right_teacher login-btn" href="#">登录</a>
            <a class="right_teacher register" href="register.html">注册</a>
            <a class="right_teacher " href="approve.html">认证</a>
        </div>
        <!----------------zhanglonghai end--------------------------------->
    </div>

    <!--轮播图-->
    <div class="swiper-container index_carousel">
        <div class="swiper-wrapper">
        </div>
        <div class="swiper-pagination"></div>
    </div>

    <!--课程区域-->

    <div class="course-wrap-container">
        <div class="swiper-wrapper" id="juZhong">

        </div>

        <div class="swiper-wrapper" id="hangDang">

        </div>
    </div>

</header>

<main>
    <div class="img-gallary">
        <div class="teacher_title">
            <div class="hot_teacher">
                <span>热门名师</span>
            </div>
        </div>
        <!--老师列表开始-->
        <div class="teacher_all">


        </div>
        <!--老师列表结束-->
    </div>
</main>
<div class="am-modal am-modal-alert" tabindex="-1" id="my-alert">
    <div class="am-modal-dialog">
        <div class="am-modal-hd">预约老师</div>
        <form class="am-form"  method="post" name="myform" id="myform">
            <div class="am-modal-bd">

                <p><input type="text" class="am-form-field am-round" name="username" id="username"
                          placeholder="请输入预约人姓名" value=""/></p>
                <p><input type="text" class="am-form-field am-round" name="phone" id="phone" placeholder="请输入预约人手机号码 " value=""/>
                </p>
            </div>
        </form>
            <div class="am-modal-footer">
                <span class="am-modal-btn" data-am-modal-cancel>取消</span>
                <span class="am-modal-btn" data-am-modal-confirm onclick="fmSubmit()">确定</span>
            </div>

    </div>
</div>
<div id="hdAlert">


</div>


<footer>
    <div class="bottom-info">
        <div class="login-wrap">
            <div class="contact-info alCenter">咨询热线 <a href="#">400-xxxxx</a></div>
            <div class="sub-txt">
                ©2017xxx xICP备14050798号-1
            </div>
        </div>
    </div>
</footer>
<script type="text/javascript" src="js/amazeui.min.js"></script>
<!--<script type="text/javascript" src="js/indexold.js"></script>-->
<script type="text/javascript" src="js/jquery.validate.min.js"></script>
<script type="text/javascript" src="js/order.js"></script>
<script type="text/javascript" src="js/swiper-3.4.2.jquery.min.js"></script>
<script>
    var mySwiper = new Swiper('.swiper-container', {
        loop: true,//可以让图片循环轮播
        autoplayDisableOnInteraction: false,//在点击之后可以继续实现轮播
        pagination: ".swiper-pagination",//让小圆点显示
        paginationClickable: true,//实现小圆点点击
        roundLengths: true,
        observer: true,
        autoplay: 3000,//可选选项，自动滑动
    });

    function fmSubmit() {
        var username = $('#username').val();
        var phone = $('#phone').val();
        sessionStorage.setItem('username',username);
        sessionStorage.setItem('phone',phone);
        $('.am-form').submit();
    }

</script>
</body>
</html>